package com.tao.common.creo.controller;


import com.github.pagehelper.PageInfo;
import com.tao.common.creo.domain.Result;
import com.tao.common.creo.domain.TableDataInfo;
import org.springframework.util.CollectionUtils;
import org.springframework.util.StringUtils;

import java.util.List;

public class BaseController {

    public TableDataInfo getTableDataInfo(List<?> list) {
        if(CollectionUtils.isEmpty(list)) {
            return TableDataInfo.empty();
        }
        return TableDataInfo.success(list, new PageInfo<>(list).getTotal());
    }
    public Result<Void> toResult(int row) {
        if(row <= 0) {
            return Result.fail();
        }
        return Result.success();
    }

    public Result<Void> toResult(Boolean result) {
        return result ? Result.success() : Result.fail();
    }
}
